import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.OSSObjectSummary;
import com.aliyun.oss.model.ObjectListing;
import org.apache.shiro.crypto.hash.Sha256Hash;
import org.junit.Test;
import pers.ljf.escloud.common.utils.FileUtils;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.List;

public class Demo {
    public static void main(String[] args) {
    }
    private static final String url = "http://ljf-node01.oss-cn-beijing.aliyuncs.com/饭了么/开发组/技术发展部/escloud.md?Expires=1645044694&OSSAccessKeyId=LTAI5tJAQu7P2rhKKKbwYa4q&Signature=EbZRsiQT6WnJ99tUKmcjDnwmOKw%3D";

    private static final String url2 = "http://ljf-node01.oss-cn-beijing.aliyuncs.com/饭了么/开发组/技术发展部/escloud.md?Expires=1645044694&amp;OSSAccessKeyId=LTAI5tJAQu7P2rhKKKbwYa4q&amp;Signature=EbZRsiQT6WnJ99tUKmcjDnwmOKw%3D";
    @Test
    public void test0() {
        System.out.println(new Sha256Hash("ldd", "123456").toHex());
    }

    @Test
    public void test2() throws UnsupportedEncodingException {
        System.out.println(new Sha256Hash("root", "DxDEYOjPgzCTmjKK092UEWCYMjZtex").toHex());
    }


    @Test
    public void test1() {
        // 创建OSSClient实例。
        String bucketName = "ljf-node01";
        String keyPrefix = "饭了么";
        OSS ossClient = new OSSClientBuilder().build("oss-cn-beijing.aliyuncs.com", "LTAI5tJAQu7P2rhKKKbwYa4q", "y5D9GWljyLTJI3dGaaaL1uAbJii7WB");
        // 列举文件。如果不设置keyPrefix，则列举存储空间下的所有文件。如果设置keyPrefix，则列举包含指定前缀的文件。
        ObjectListing objectListing = ossClient.listObjects(bucketName, keyPrefix);
        //ossClient.
        List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
        for (OSSObjectSummary s : sums) {
            System.out.println("\t" + s.getKey());
        }
        // 关闭OSSClient。
        ossClient.shutdown();
    }

    @Test
    public void test3(){
        File file = FileUtils.getNetUrlHttps("https://ljf-gulimall.oss-cn-beijing.aliyuncs.com/img/20210607163831.png");
        System.out.println(file.getName());
    }
}
